package com.lysh.test.netty;

import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import lombok.extern.slf4j.Slf4j;

/**
 * @author liyishan
 * @date 2023/8/24 11:42
 * @apiNote
 */
@Slf4j

public abstract class AbstractServerHandler<T> extends SimpleChannelInboundHandler<T> {
    @Override
    public void channelActive(ChannelHandlerContext channelHandlerContext) throws Exception {
        System.out.println("channelActive");
    }

    @Override
    public void handlerAdded(ChannelHandlerContext channelHandlerContext) throws Exception {
        log.info("handlerAdded");
    }

    @Override
    public void channelInactive(ChannelHandlerContext channelHandlerContext) throws Exception {
        System.out.println("channelInactive");
    }

    @Override
    public void handlerRemoved(ChannelHandlerContext channelHandlerContext) throws Exception {
        log.info("handlerRemoved");
    }

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, T t) throws Exception {
        channelRead(ctx.channel(), t);
    }
    public abstract void channelRead(Channel channel, T msg);
}
